<?php
	
	$site_root = "";
	require_once ($site_root . "common/PinSQL.obj");
	$pinSQL = new PinSQL();

	$username = $_POST['username'];
	$password = $_POST['password'];
	
	$page = $_GET['page'];
	
	if (!$page)
	{
		$page = "/frame.php?page=home.php";
	}
	
	$pinSQL->Query("SELECT * FROM members WHERE BINARY username='$username' AND password='$password'");
	if ( $pinSQL->GetNumRows() )
	{
		
		$firstname = $pinSQL->getEntry(0, 'firstname');
		$lastname = $pinSQL->getEntry(0, 'lastname');
		$email = $pinSQL->getEntry(0, 'email');
		$level = $pinSQL->getEntry(0, 'level');
		$id = $pinSQL->getEntry(0, 'ID');
		
		session_register('username');
		session_register('firstname');
		session_register('lastname');
		session_register('email');
		session_register('level');
		session_register('id');

		header("Location: $page");
	} else {
		header("Location: index.php?event=badlogin");
	}
	
	$pinSQL->Close();
	
?>